import type { Middleware } from '../types';

export function createUnlessMiddleware(
  pred: (req: Request) => boolean,
  middleware: Middleware
) {
  return function UnlessMiddleware(req, res, next) {
    if (pred(req)) {
      next(); // Skip this middleware.
    } else {
      middleware(req, res, next); // Allow this middleware.
    }
  };
}
